#!/bin/python3
# -*- coding: UTF-8
import sys
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.colors
import matplotlib.dates as mdates
from matplotlib.ticker import ScalarFormatter
from matplotlib.ticker import LogFormatter
from matplotlib.ticker import MultipleLocator
from matplotlib.ticker import FormatStrFormatter
from matplotlib.font_manager import findfont, FontProperties  
import matplotlib.font_manager as font_manager
import matplotlib.ticker as mtick
import seaborn as sns
from scipy.stats.mstats import gmean



def calculate_geomean(datay):
	print (datay)
	ret = gmean(datay)
	print (ret)
	return ret

# 读文件
def read_data(file_path):
	data = np.loadtxt(file_path,dtype=str,delimiter='\t')
	return data

def filter(data, x):
	return data[data[:, 0] == x, 1:]

def uniqx(data):
	return np.unique(data[:, 0])

def avg_all(data, x):
	ret = np.average(data[:, 0] == x, axis = 0)
	return ret

filename = sys.argv[1]
data = read_data(filename)

# 获得所有bench名字(除去第一行)
bench_name = uniqx(data[1:])
# 获得所有colib名字
lib_name = uniqx(filter(data, bench_name[0]))
for bench in bench_name:
	for lib in lib_name:
		# 多次执行结果 计算平均值和标准差
		result_data = filter(filter(data, bench), lib).astype(int)
		print("%s %s %.3f %.3f" % (bench, lib, np.mean(result_data), np.std(result_data)))


#  所有bench计算几何平均数